<template>
  <div id="egg">  

    <div  style="display:flex;margin-bottom:10px;align-items: center;">
            <img class="top_img" src="@/assets/images/a8.png" style="width:35px;height:35px;margin-right:10px;"/>
            <div style="line-height: 40px;font-weight:bold:">扭蛋管理</div>
     </div> 
   <el-form ref="form" label-width="70px" style="width:100%;">
     <div style="display:flex;align-items: center;">
            <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">查询项</div> 
           <el-form-item label="手机号码">
                <el-input v-model="form.phone" placeholder="姓名/手机号" style="width:140px;"></el-input>
           </el-form-item>  
            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but1()">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but()">清 空</div>    
            </div> 
        </div>

        <div style="display:flex;align-items: center;">
            <div style="width:50px;text-align-last: justify;margin-top:-12px;font-size: 14px;color: #606266;margin-right:10px;">筛选项</div> 
             
             
             <el-form-item label="生成时间"  >
                    <el-date-picker  type="date"   placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="form.onedate" style="width:140px;"> 
                    </el-date-picker>
              </el-form-item>

             <el-form-item label="扭蛋类别"   style="margin-left:10px;">
                <el-select  v-model="form.select_num2" placeholder="扭蛋类别" style="width:140px;" @change="select_up()"> 
                    <el-option  v-for="(item,index) in select_data2" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
             </el-form-item>

            <el-form-item label="是否发放" style="margin-left:10px;" v-if="isshow_up">
                <el-select  v-model="form.select_num1" placeholder="是否发放" style="width:140px;">
                    <el-option  v-for="(item,index) in select_data1" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
             </el-form-item>

             
              <el-form-item label="兑换方式" style="margin-left:10px;" v-if="isshow_zt">
                <el-select  v-model="form.select_num3" placeholder="兑换方式" style="width:140px;">
                    <el-option  v-for="(item,index) in select_data3" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
             </el-form-item>




            <div class="buttoon_box">
                <div class="buttoon_box_item"  style="margin-left:10px;background:#FFC600;color:white;" @click="search_but2()">确 定</div>
                <div class="buttoon_box_item" style="margin-left:10px;border:1px solid #D9D9D9;" @click="sx_but()">清 空</div>    
            </div>
        </div>

    <el-row>
        <el-col :span="24" style="text-align: right;">    
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk1_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg4.png" />金蛋管理
            </el-button>     
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk2_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg4.png" />银蛋管理
            </el-button> 
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk3_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg4.png" />彩蛋管理
            </el-button>   
            <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk4_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg6.png" />基础设置
            </el-button>   
             <el-button type="primary" class="custom_color_button1" style="margin-bottom:10px;" @click="mtk5_but()">
              <img class="custom_color_button1_img" src="@/assets/images/but_bg9.png" />奖池查询
            </el-button>   
        </el-col>
     </el-row>

      </el-form>

   <!-- 渲染数据list -->
   <egg-list :datalist="datalist" @up_list_fun="list_fun"> </egg-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>


      <!-- 金蛋管理 -->
    <el-dialog title="金蛋管理" :visible.sync="mtk1"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
                <el-form-item label="手续费">
                        <el-input    v-model="mtk1_form.gdb_goods_cash_reward_charge" placeholder="手续费"></el-input>
                </el-form-item> 
                <el-form-item label="价值门槛">
                        <el-input    v-model="mtk1_form.gdb_goods_cash_price_limit" placeholder="价值门槛"></el-input>
                </el-form-item>
                <el-form-item label="消耗次数">
                       <el-switch  
                            :active-value="mtk1_form.active" 
                            :inactive-value="mtk1_form.isactive" 
                            v-model="mtk1_form.gdb_goods_cash_consume" 
                            @change="switchchange1()"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"
                            > 
                        </el-switch>
                </el-form-item>
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>


      <!-- 彩蛋管理 -->
    <el-dialog title="彩蛋管理" :visible.sync="mtk3"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
                <el-form-item label="手续费">
                        <el-input    v-model="mtk3_form.gdb_goods_cash_range_reward_charge" placeholder="手续费"></el-input>
                </el-form-item> 
                <el-form-item label="价值门槛">
                        <el-input    v-model="mtk3_form.gdb_goods_cash_range_price_limit" placeholder="价值门槛"></el-input>
                </el-form-item>
                <el-form-item label="消耗次数">
                       <el-switch  
                            :active-value="mtk3_form.active" 
                            :inactive-value="mtk3_form.isactive" 
                            v-model="mtk3_form.gdb_goods_cash_range_consume" 
                            @change="switchchange3()"  
                            active-color="#F5CF49" 
                            inactive-color="#E5E5E5"
                            > 
                        </el-switch>
                </el-form-item>
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk3_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>


    <!-- 基础设置 -->
    <el-dialog title="次数获得" :visible.sync="mtk4"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">     
                 <el-form-item label="好友">
                        <el-input    v-model="mtk4_form.invite_count" placeholder="好友"></el-input>
                </el-form-item>
                <el-form-item label="团队">
                        <el-input    v-model="mtk4_form.team_count" placeholder="团队"></el-input>
                </el-form-item>
                <el-form-item label="经验">
                        <el-input    v-model="mtk4_form.experience" placeholder="经验"></el-input>
                </el-form-item>
            </el-form>
            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk4_qr_but()">确认</el-button>
            </div>

        </div> 
    </el-dialog>

      
  </div>
</template>

<script>
import EggList from '@/view/Activitynew/Egg/EggList'
export default {
  name: 'egg',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        form:{
             phone:'',
             onedate:'',
             select_num1:'',
             select_num2:'',
             select_num3:'',
        },
        select_data1:[{"id":1,"name":"已发放"},{"id":2,"name":"未发放"},{"id":3,"name":"已驳回"}],
        select_data2:[{"id":2,"name":"金蛋"},{"id":1,"name":"银蛋"},{"id":3,"name":"彩蛋"}],
        select_data3:[{"id":1,"name":"金蜜"},{"id":2,"name":"蜜贝"}],

        mtk1:false,
        mtk1_form:{
            gdb_goods_cash_reward_charge:'',
            gdb_goods_cash_price_limit:'',
            active:1, 
            isactive:0, 
            gdb_goods_cash_consume:0
        },


        mtk3:false,
        mtk3_form:{
            gdb_goods_cash_range_reward_charge:'',
            gdb_goods_cash_range_price_limit:'',
            active:1, 
            isactive:0, 
            gdb_goods_cash_range_consume:0
        },

        mtk4:false,
        mtk4_form:{
            number1:'',
            invite_count:'',
            team_count:'',
            experience:'',
        },

        isshow_up:true,
        isshow_zt:true,
        infor_row:{}
    }
  },
 components:{
    EggList
  },
  created(){
       this.list_fun()
       this.limit_fun()
  },
  mounted (){
    
  },
  methods: {
    limit_fun(){
        this.post("/draw_lottery/goldAndColorItem", {
	        }).then(res => {
            this.mtk4_form.experience = res.result.experience //经验值
            this.mtk4_form.team_count = res.result.team_count //团队
            this.mtk4_form.invite_count = res.result.invite_count //好友

            this.mtk1_form.gdb_goods_cash_consume =  parseInt(res.result.gdb_goods_cash_consume)  //  金蛋开关
            this.mtk1_form.gdb_goods_cash_price_limit = res.result.gdb_goods_cash_price_limit //  金蛋价值
            this.mtk1_form.gdb_goods_cash_reward_charge = res.result.gdb_goods_cash_reward_charge   //  金蛋手续费

            this.mtk3_form.gdb_goods_cash_range_consume =  parseInt(res.result.gdb_goods_cash_range_consume)  //  彩蛋开关
            this.mtk3_form.gdb_goods_cash_range_price_limit = res.result.gdb_goods_cash_range_price_limit //  彩蛋价值
            this.mtk3_form.gdb_goods_cash_range_reward_charge = res.result.gdb_goods_cash_range_reward_charge   //  彩蛋手续费

            //console.log(res.result,"dddd")
         })
    },
    list_fun(){
      
        this.post("/draw_lottery/listOfWinPrize", {
              page:this.page,
              account:this.form.phone,
              onedate:this.form.onedate,
              type:this.form.select_num2,
              status:this.form.select_num1,
              mode:this.form.select_num3,
	        }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list

             for(let item of this.datalist) {
               
               if(item.qr_code){
                   for(let a of item.qr_code) {
                   if(a.collection_type == 1){
                      item.srcListwx = a.collection_picture
                      item.srcList1 = [this.urlimg + a.collection_picture]
                   }else if(a.collection_type == 2){
                      item.srcListzfb = a.collection_picture
                      item.srcList2 = [this.urlimg + a.collection_picture]
                   }else if(a.collection_type == 5){
                      item.srcListyhk = a.collection_picture
                      item.srcList5 = [this.urlimg + a.collection_picture]
                   }
                }  
               }
                            
                    
             }

            console.log(res,"aaa")
         })

    },
    select_up(){
      if(this.form.select_num2 == 1){
          this.form.select_num1 = ''
          this.form.select_num3 = ''
          this.isshow_up = false
          this.isshow_zt = true
      }else{
           this.isshow_up = true
           this.isshow_zt = false
      }
    },
    mtk1_but(){
        this.mtk1 = true
    },
    switchchange1(){
         
    },
    mtk1_qr_but(){
         this.post("/draw_lottery/setGoldItem", {
                    consume:this.mtk1_form.gdb_goods_cash_consume,
                    price_limit:this.mtk1_form.gdb_goods_cash_price_limit,
                    service_charge:this.mtk1_form.gdb_goods_cash_reward_charge,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk1 = false
                      this.limit_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
    },
    mtk2_but(){
      this.$router.push({
        path: '/index/activitynew/egg/prize',
        query: {
          
        }
      })
    },
    mtk3_but(){
        this.mtk3 = true
    },
    mtk3_qr_but(){
         this.post("/draw_lottery/setColorItem", {
                    consume:this.mtk3_form.gdb_goods_cash_range_consume,
                    price_limit:this.mtk3_form.gdb_goods_cash_range_price_limit,
                    service_charge:this.mtk3_form.gdb_goods_cash_range_reward_charge,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk3 = false
                      this.limit_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
    },
    switchchange3(){

    },
    mtk4_but(){
        this.mtk4 = true
    },
    mtk4_qr_but(){
        this.post("/draw_lottery/setBasics", {
                    experience:this.mtk4_form.experience,
                    invite_count:this.mtk4_form.invite_count,
                    team_count:this.mtk4_form.team_count,
                }).then(res => {

                    if(res.error_code == 0){
                      this.mtk4 = false
                      this.limit_fun()
                     this.open1(res.result,'success')  //提示框
                    }else {
                     this.open1(res.message,'warning')
                }

         })
    },
    mtk5_but(){
        this.$router.push({
        path: '/index/activitynew/egg/jackpot',
        query: {
          
        }
       })
    },
    search_but1(){
      this.page = 1
      this.list_fun()
    },
    search_but2(){
      this.page = 1
      this.list_fun()
    },
    sx_but(){
      this.page = 1
      this.form={
            phone:'',
            onedate:'',
            select_num1:'',
            select_num2:'',
            select_num3:'',
      }
      this.list_fun()
    },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>
.mytitle{
    height: 50px;
}
.mytitle_item{
    display: flex;
    align-items: center;
}
.mytitle_item::before{
  content:'';
  width: 5px;
  height: 15px;
  background: #409EFF;
  display: block;
  margin-right: 5px;
}
.buttoon_box{
  display:flex;margin-bottom:10px;
}
.buttoon_box_item{
  height:40px;line-height:40px;width:60px;font-size:14px;text-align:center;border-radius:5px;
}
.el-input-box>>>input{
  padding: 0px 3px !important;
}
</style>
